<!DOCTYPE HTML>
<html>
<head>
<title>EnvGet | AutoHotkey</title>
<meta name="description" content="The EnvGet command retrieves an environment variable." />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>EnvGet <span class="ver">[v1.0.43.08+]</span></h1>

<p>获取环境变量的内容.</p>

<pre class="Syntax"><span class="func">EnvGet</span>, OutputVar, EnvVarName</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>OutputVar</dt>
  <dd><p>用来存储字符串的变量名.</p></dd>

  <dt>EnvVarName</dt>
  <dd><p>要获取的<a href="../Concepts.htm#environment-variables">环境变量</a>的名称. 例如: <code>EnvGet, OutputVar, Path</code>.</p></dd>

</dl>
<h2 id="Remarks">备注</h2>
<p>如果指定的环境变量为空或不存在, 那么 <em>OutputVar</em> 被置空.</p>
<p>操作系统限制每个环境变量的文本最多为 32 KB.</p>
<h2 id="Related">相关</h2>
<p><a href="EnvSet.htm">EnvSet</a>, <a href="_NoEnv.htm">#NoEnv</a>, <a href="../Concepts.htm#environment-variables">环境变量</a>, <a href="EnvUpdate.htm">EnvUpdate</a>, <a href="SetEnv.htm">SetEnv</a>, <a href="Run.htm">Run</a>, <a href="Run.htm">RunWait</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a class="ex_number" href="#ExBasic"></a> 检索一个环境变量, 并将其值存储在 <var>OutputVar</var> 中.</p>
<pre>EnvGet, OutputVar, LogonServer</pre>
</div>

<div class="ex" id="ExProgramFiles">
<p><a class="ex_number" href="#ExProgramFiles"></a> 检索并报告 "Program Files" 目录的路径. 有关替代方法, 请参阅 <a href="RegRead.htm#ExProgramFiles">RegRead 示例 #2</a>.</p>
<pre>EnvGet, OutputVar, % <a href="../Variables.htm#Is64bitOS">A_Is64bitOS</a> ? "ProgramW6432" : "ProgramFiles"
MsgBox, Program files are in: %OutputVar%</pre>
</div>

</body>
</html>